package com.xueyi.workflow.event;

import org.springframework.context.ApplicationEvent;

/**
 * 流程状态变更事件
 * 当流程实例状态发生变化时发布此事件
 *
 * @author xueyi
 * @date 2024-08-26
 */
public class ProcessStatusChangedEvent extends ApplicationEvent {
    
    private final String processInstanceId;
    private final String businessKey;
    private final String processDefinitionKey;
    private final String oldStatus;
    private final String newStatus;
    private final String reason;
    private final Object additionalData;
    
    public ProcessStatusChangedEvent(Object source, String processInstanceId, String businessKey, 
                                   String processDefinitionKey, String oldStatus, String newStatus, 
                                   String reason, Object additionalData) {
        super(source);
        this.processInstanceId = processInstanceId;
        this.businessKey = businessKey;
        this.processDefinitionKey = processDefinitionKey;
        this.oldStatus = oldStatus;
        this.newStatus = newStatus;
        this.reason = reason;
        this.additionalData = additionalData;
    }
    
    public ProcessStatusChangedEvent(Object source, String processInstanceId, String businessKey, 
                                   String processDefinitionKey, String oldStatus, String newStatus) {
        this(source, processInstanceId, businessKey, processDefinitionKey, oldStatus, newStatus, null, null);
    }
    
    public ProcessStatusChangedEvent(Object source, String processInstanceId, String businessKey, 
                                   String processDefinitionKey, String oldStatus, String newStatus, String reason) {
        this(source, processInstanceId, businessKey, processDefinitionKey, oldStatus, newStatus, reason, null);
    }
    
    // Getters
    public String getProcessInstanceId() { return processInstanceId; }
    public String getBusinessKey() { return businessKey; }
    public String getProcessDefinitionKey() { return processDefinitionKey; }
    public String getOldStatus() { return oldStatus; }
    public String getNewStatus() { return newStatus; }
    public String getReason() { return reason; }
    public Object getAdditionalData() { return additionalData; }
}
